NET Link Tracker
Quick Start C#

Create Expiring URL

LinkLogic linkLogic = new LinkLogic(); //Trial Mode

LinkLogic linkLogicLicensed = new LinkLogic("place user name here", "place license key here");  //License Mode


//Use a in memory mock database for testing

ILinkTrackerDatabaseLogic databaseLogic = new LinkTrackerMockDatabase();

linkLogic.DatabaseLogic = databaseLogic;

//Create a link to a URL that will expire in 30 days

TrackedLink createdLink = linkLogic.CreateExpiringUrl("http://www.google.com", 30);

TrackedLink link = linkLogic.GetLinkByGuid(createdLink.LinkGuid);
LinkStatus status = linkLogic.CheckLinkStatus(link);

//The status will be Active

Console.WriteLine("Status: " + status);

//Get a friendly status for the user

Console.WriteLine("Friendly Status: " + linkLogic.GetFriendlyStatus(link));

//Force the link to expire

link.ExpirationDate = DateTime.Now.AddDays(-1); databaseLogic.SaveTrackedLink(link); status = linkLogic.CheckLinkStatus(link);

  //The status will be Expired

Console.WriteLine("Status: " + status);

//Get a expired friendly status for the user

Console.WriteLine("Friendly Status: " + linkLogic.GetFriendlyStatus(link));

//Get the associated URL

Console.WriteLine("URL: " + createdLink.FilePathOrUrl);

//This will perform a Response.Redirect

if (HttpContext.Current != null) //This check not needed if running in ASP.NET process    

linkLogic.ProcessLink(createdLink);

Create Expiring Download Link

LinkLogic linkLogic = new LinkLogic(); //Trial Mode
LinkLogic linkLogicLicensed = new LinkLogic("place user name here", "place license key here");  //License Mode
 
//Use a in memory mock database for testing
ILinkTrackerDatabaseLogic databaseLogic = new LinkTrackerMockDatabase();
 
linkLogic.DatabaseLogic = databaseLogic;
 
//Create a dummy file for testing
string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test.txt");
File.WriteAllText(filePath,"This is a test");
 
//Create a link to a file that will expire in 30 days
TrackedLink createdLink = linkLogic.CreateExpiringDownload(filePath, 30);
 
TrackedLink link = linkLogic.GetLinkByGuid(createdLink.LinkGuid);
LinkStatus status = linkLogic.CheckLinkStatus(link);
 
//The status will be Active
Console.WriteLine("Status: " + status);
 
//Get a friendly status for the user
Console.WriteLine("Friendly Status: " + linkLogic.GetFriendlyStatus(link));
 
//Force the link to expire
link.ExpirationDate = DateTime.Now.AddDays(-1);
databaseLogic.SaveTrackedLink(link);
 
status = linkLogic.CheckLinkStatus(link);
 
//The status will be Expired
Console.WriteLine("Status: " + status);
 
//Get a expired friendly status for the user
Console.WriteLine("Friendly Status: " + linkLogic.GetFriendlyStatus(link));
 
//Get the associated File Path
Console.WriteLine("File Path:  " + createdLink.FilePathOrUrl);
 
//This will stream the file to the browser
if (HttpContext.Current != null) //This check not needed if running in ASP.NET process
    linkLogic.ProcessLink(createdLink);

 

Create Custom Link

 LinkLogic linkLogic = new LinkLogic(); //Trial Mode

LinkLogic linkLogicLicensed = new LinkLogic("place user name here", "place license key here");  //License Mode


//Use a in memory mock database for testing

ILinkTrackerDatabaseLogic databaseLogic = new LinkTrackerMockDatabase();

linkLogic.DatabaseLogic = databaseLogic;

//Create a dummy file for testing

string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test.txt");
File.WriteAllText(filePath, "This is a test");

//Create a link that expires 1 year from now, with a maximum of 10 IP Addresss, and a maximum of 2 requests per day LinkParms parms = new LinkParms();
parms.IsUrl = false;
parms.ExpirationDate = DateTime.Now.AddYears(1);
parms.MaxIpAddresses = 10;
parms.MaxRequestsPerDay = 2;
parms.FilePathOrUrl = filePath;

TrackedLink createdLink = linkLogic.CreateLink(parms);

//Check the status

TrackedLink link = linkLogic.GetLinkByGuid(createdLink.LinkGuid);
LinkStatus status = linkLogic.CheckLinkStatus(link);

//The status will be Active

Console.WriteLine("Status: " + status);

//Get a friendly status for the user

Console.WriteLine("Friendly Status: " + linkLogic.GetFriendlyStatus(link));

//Force the link to expire link.ExpirationDate = DateTime.Now.AddDays(-1);
databaseLogic.SaveTrackedLink(link);

status = linkLogic.CheckLinkStatus(link);

//The status will be Expired

Console.WriteLine("Status: " + status);

//Get a expired friendly status for the user

Console.WriteLine("Friendly Status: " + linkLogic.GetFriendlyStatus(link));

//Get the associated File Path

Console.WriteLine("File Path: " + createdLink.FilePathOrUrl);

//This will stream the file to the browser

if (HttpContext.Current != null) //This check not needed if running in ASP.NET process    

linkLogic.ProcessLink(createdLink);